<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>累加{{count}}</h1>
    <button @click="add">点击累加1</button>
    <button @click="decrement(1,$event)">点击累减1</button>
    <button @click="addn(5)">点击累加n</button>
  </div>
  <script>
    Vue.config.productionTip = false
    const vm = new Vue({
      el:"#app",
      data(){
        return {
          msg:"hello vue",
          count:0
        }
      },
      methods:{
        // 1.使用事件函数时括号可加可不加,
        //2.如果使用事件函数时不加括号,这个事件函数的第一个形参是event对象
        //3.如果使用事件函数时加了括号,需要在实参中传入$event固定字符,用形参接收,这个值就是event事件对象
        add(e){
          console.log(e,'$event');
          this.count++
        },
        decrement(num,e){
          console.log(num,e,'num,e');
          this.count--
        },
        addn(n){
          this.count+=n
        }
      }
    })
    </script>
</body>
</html>